package com.qjc.demo.chain.handler;

import com.qjc.demo.chain.service.IChainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 将每个责任连起来从而形成责任链
 *
 * @ClassName: ChainHandler
 * @Author: qjc
 * @Date: 2023/5/10 10:51
 */
@Service
public class ChainHandler {

    @Resource
    private List<IChainService> chainServiceList;


    public String process(String param) {
        String result = "";
        for (IChainService chainService : chainServiceList) {
            String subResult = chainService.checkParameters(param);
            result += subResult;
        }
        return result;
    }

}
